<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
 <head>
  <title>inputEx - SerializeField Usage</title>

<!-- YUI CSS -->
<link rel="stylesheet" type="text/css" href="../lib/yui/reset-fonts/reset-fonts.css">
<link rel="stylesheet" type="text/css" href="../lib/yui/container/assets/container.css"> 
<link rel="stylesheet" type="text/css" href="../lib/yui/assets/skins/sam/skin.css">

<!-- InputEx CSS -->
<link type='text/css' rel='stylesheet' href='../css/inputEx.css' />

<!--[if IE 6]>
<link type='text/css' rel='stylesheet' href='../css/inputEx-IE6.css' />
<![endif]-->

<!-- Demo CSS -->
<link rel="stylesheet" type="text/css" href="css/demo.css"/>
<link rel="stylesheet" type="text/css" href="css/dpSyntaxHighlighter.css">

 </head>

 <body>

<h1>inputEx - SerializeField Usage</h1>


<!-- Example 1 -->
<div class='exampleDiv'>
	<h2>Basic SerializeField creation</h2>
	<p></p>
	<div class='demoContainer' id='container1'></div>
	<div class='codeContainer'>
		<textarea name="code" class="JScript">
			var field = new inputEx.SerializeField({
				parentEl: 'container1', 
				label: 'Your name',
				description: 'Please enter your name',
				
				subfield: {
							type: 'group',
							fields: [
								{ name: 'firstname', typeInvite: 'firstname' },
								{ name: 'lastname', typeInvite: 'lastname' }
							],
							required:true
				}
				
			});

		   var el = YAHOO.util.Dom.get('container1');

			var button1 = inputEx.cn('button', null, null, "SetValue with '{\"firstname\":\"Jimi\",\"lastname\":\"Hendrix\"}'");
			el.appendChild(button1);
			YAHOO.util.Event.addListener(button1, "click" ,function() {
			   field.setValue('{"firstname":"Jimi","lastname":"Hendrix"}');
			});

			var logDiv = inputEx.cn('div', null, null, "Log :");
			el.appendChild(logDiv);
			field.updatedEvt.subscribe(function(e,params) {
				var value = params[0];
				logDiv.innerHTML += "Updated at "+(new Date())+" with value "+value;
				logDiv.appendChild(inputEx.cn('br'));
			});
		</textarea>
	</div>
</div>



<!-- Example 2 -->
<div class='exampleDiv'>
	<h2>XML serialization</h2>
	<p>There is an issue because ObjTree needs only 1 root element :</p>
	<div class='demoContainer' id='container2'></div>
	<div class='codeContainer'>
		<textarea name="code" class="JScript">
			var field = new inputEx.SerializeField({
				parentEl: 'container2', 
				label: 'Your name',
				description: 'Please enter your name',
				
				serializer: 'xml',
				
				subfield: {
							type: 'group',
							fields: [
								{
									type: 'group',
									name: 'person',
									fields: [
										{ name: 'firstname', typeInvite: 'firstname' },
										{ name: 'lastname', typeInvite: 'lastname' }
									]
								}
							]
				}
				
			});

		   var el = YAHOO.util.Dom.get('container2');
			
			var button2 = inputEx.cn('button', null, null, "SetValue");
			el.appendChild(button2);
			YAHOO.util.Event.addListener(button2, "click" ,function() {
				var xml = String.fromCharCode(60)+'?xml version="1.0" encoding="UTF-8" ?'+String.fromCharCode(62)+String.fromCharCode(60)+'person'+String.fromCharCode(62)+String.fromCharCode(60)+'firstname'+String.fromCharCode(62)+'Jimi'+String.fromCharCode(60)+'/firstname'+String.fromCharCode(62)+String.fromCharCode(60)+'lastname'+String.fromCharCode(62)+'Hendrix'+String.fromCharCode(60)+'/lastname'+String.fromCharCode(62)+String.fromCharCode(60)+'/person'+String.fromCharCode(62);
				field.setValue(xml);
			});

			var logDiv = inputEx.cn('div', null, null, "Log :");
			el.appendChild(logDiv);
			field.updatedEvt.subscribe(function(e,params) {
				var value = params[0].replace( new RegExp(String.fromCharCode(60),"g") , '&lt;' ).replace( new RegExp(String.fromCharCode(62),"g") , '&gt;' );
				logDiv.innerHTML += "Updated at "+(new Date())+" with value "+value;
				logDiv.appendChild(inputEx.cn('br'));
			});
		</textarea>
	</div>
</div>


<script type="text/javascript" src="../lib/XML/ObjTree.js"></script>

<!-- YUI Library -->
<script type="text/javascript" src="../lib/yui/utilities/utilities.js"></script>
<script type="text/javascript" src="../lib/yui/container/container-min.js"></script>
<script type="text/javascript" src="../lib/yui/json/json-min.js"></script>

<!-- InputEx -->
<script src="../js/inputex.js"  type='text/javascript'></script>
<script src="../js/mixins/choice.js"  type='text/javascript'></script>
<script src="../js/Field.js"  type='text/javascript'></script>
<script src="../js/Group.js"  type='text/javascript'></script>
<script src="../js/fields/StringField.js"  type='text/javascript'></script>
<script src="../js/fields/SelectField.js"  type='text/javascript'></script>
<script src="../js/fields/CombineField.js"  type='text/javascript'></script>
<script src="../js/fields/TimeField.js"  type='text/javascript'></script>
<script src="../js/fields/DateField.js"  type='text/javascript'></script>
<script src="../js/fields/SerializeField-beta.js"  type='text/javascript'></script>

<!-- inputEx examples -->
<script src="js/dpSyntaxHighlighter.js"></script>
<script src="inputex-examples.js"></script>

 </body>
</html>